﻿using System.Collections.Generic;

namespace com.binance.client.model.enums
{
	/// <summary>
	/// 1min, 5min, 15min, 30min, 60min, 1day, 1mon, 1week, 1year
	/// </summary>
	public sealed class CandlestickInterval
	{
		public static readonly CandlestickInterval ONE_MINUTE = new CandlestickInterval("ONE_MINUTE", InnerEnum.ONE_MINUTE, "1m");
		public static readonly CandlestickInterval THREE_MINUTES = new CandlestickInterval("THREE_MINUTES", InnerEnum.THREE_MINUTES, "3m");
		public static readonly CandlestickInterval FIVE_MINUTES = new CandlestickInterval("FIVE_MINUTES", InnerEnum.FIVE_MINUTES, "5m");
		public static readonly CandlestickInterval FIFTEEN_MINUTES = new CandlestickInterval("FIFTEEN_MINUTES", InnerEnum.FIFTEEN_MINUTES, "15m");
		public static readonly CandlestickInterval HALF_HOURLY = new CandlestickInterval("HALF_HOURLY", InnerEnum.HALF_HOURLY, "30m");
		public static readonly CandlestickInterval HOURLY = new CandlestickInterval("HOURLY", InnerEnum.HOURLY, "1h");
		public static readonly CandlestickInterval TWO_HOURLY = new CandlestickInterval("TWO_HOURLY", InnerEnum.TWO_HOURLY, "2h");
		public static readonly CandlestickInterval FOUR_HOURLY = new CandlestickInterval("FOUR_HOURLY", InnerEnum.FOUR_HOURLY, "4h");
		public static readonly CandlestickInterval SIX_HOURLY = new CandlestickInterval("SIX_HOURLY", InnerEnum.SIX_HOURLY, "6h");
		public static readonly CandlestickInterval EIGHT_HOURLY = new CandlestickInterval("EIGHT_HOURLY", InnerEnum.EIGHT_HOURLY, "8h");
		public static readonly CandlestickInterval TWELVE_HOURLY = new CandlestickInterval("TWELVE_HOURLY", InnerEnum.TWELVE_HOURLY, "12h");
		public static readonly CandlestickInterval DAILY = new CandlestickInterval("DAILY", InnerEnum.DAILY, "1d");
		public static readonly CandlestickInterval THREE_DAILY = new CandlestickInterval("THREE_DAILY", InnerEnum.THREE_DAILY, "3d");
		public static readonly CandlestickInterval WEEKLY = new CandlestickInterval("WEEKLY", InnerEnum.WEEKLY, "1w");
		public static readonly CandlestickInterval MONTHLY = new CandlestickInterval("MONTHLY", InnerEnum.MONTHLY, "1M");

		private static readonly IList<CandlestickInterval> valueList = new List<CandlestickInterval>();

		static CandlestickInterval()
		{
			valueList.Add(ONE_MINUTE);
			valueList.Add(THREE_MINUTES);
			valueList.Add(FIVE_MINUTES);
			valueList.Add(FIFTEEN_MINUTES);
			valueList.Add(HALF_HOURLY);
			valueList.Add(HOURLY);
			valueList.Add(TWO_HOURLY);
			valueList.Add(FOUR_HOURLY);
			valueList.Add(SIX_HOURLY);
			valueList.Add(EIGHT_HOURLY);
			valueList.Add(TWELVE_HOURLY);
			valueList.Add(DAILY);
			valueList.Add(THREE_DAILY);
			valueList.Add(WEEKLY);
			valueList.Add(MONTHLY);
		}

		public enum InnerEnum
		{
			ONE_MINUTE,
			THREE_MINUTES,
			FIVE_MINUTES,
			FIFTEEN_MINUTES,
			HALF_HOURLY,
			HOURLY,
			TWO_HOURLY,
			FOUR_HOURLY,
			SIX_HOURLY,
			EIGHT_HOURLY,
			TWELVE_HOURLY,
			DAILY,
			THREE_DAILY,
			WEEKLY,
			MONTHLY
		}

		public readonly InnerEnum innerEnumValue;
		private readonly string nameValue;
		private readonly int ordinalValue;
		private static int nextOrdinal = 0;

		private readonly string code;

		internal CandlestickInterval(string name, InnerEnum innerEnum, string code)
		{
			this.code = code;

			nameValue = name;
			ordinalValue = nextOrdinal++;
			innerEnumValue = innerEnum;
		}

		public override string ToString()
		{
			return code;
		}

		public static IList<CandlestickInterval> values()
		{
			return valueList;
		}

		public int ordinal()
		{
			return ordinalValue;
		}

		public static CandlestickInterval valueOf(string name)
		{
			foreach (CandlestickInterval enumInstance in CandlestickInterval.valueList)
			{
				if (enumInstance.nameValue == name)
				{
					return enumInstance;
				}
			}
			throw new System.ArgumentException(name);
		}
	}

}